<?php

namespace App\Http\Middleware;

use \Log;
use Closure;

class ApiBefore {

  public function handle($requst, Closure $next) {
      Log::info("request params：".json_encode($requst->all()) );
      $res = $next($requst);
      $res->header('Access-Control-Allow-Origin', '*');
      $res->header('Access-Control-Allow-Credentials', 'true');
      $res->header('Access-Control-Allow-Headers', 'Origin, Content-Type, Cookie, Accept');
      $res->header('Access-Control-Allow-Methods', 'GET, POST, PATCH, PUT, OPTIONS');
      Log::info("response res：".json_encode($res->original));

      $res->original = [
          'msg'=>"success",
          "status"=>0,
          "data"=>$res->original,
      ];

      return $res;
  }
}
